package mtm.ui.list;

import java.awt.Color;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.ByteArrayInputStream;
import java.io.IOException;

public class JobTransferable implements Transferable {

	protected static DataFlavor customDataFlavor = JobDataFlavor.getInstance();
	protected static DataFlavor[] supportedFlavors = { customDataFlavor };

	private JobItem item;

	/**
	 * Constructor
	 * 
	 * @param color
	 * @param text
	 */
	public JobTransferable(JobItem item) {
		this.item = item;
	}

	/** Return a list of DataFlavors we can support */
	public DataFlavor[] getTransferDataFlavors() {
		return supportedFlavors;
	}

	/**
	 * Check whether a specified DataFlavor is available
	 */
	public boolean isDataFlavorSupported(DataFlavor flavor) {
		return flavor.equals(customDataFlavor);
	}

	/**
	 * Return data of this Transferable object
	 */
	public Object getTransferData(DataFlavor flavor)
			throws UnsupportedFlavorException, IOException {
		if (flavor.equals(customDataFlavor))
			return item;
		else
			throw new UnsupportedFlavorException(flavor);
	}
}
